import { ICondition } from '../../interfaces';
import service from './service';

/**
 * 调用java dsd服务
 * @param systemid 产品 systemid
 * @param refsystemid 产品 refsystemid
 * @param modelid 服务名
 * @param condition 参数
 * @returns 服务返回结果
 * @example const res=await javadsd(systemid, refsystemid, modelid, condition, cache, force_update_cache);
 */
export default async function javadsd<T>(systemid: string, refsystemid: string, modelid: string, condition: ICondition, cache: boolean, force_update_cache: boolean) {
	if (!condition) {
		condition = {
			paging: {
				index: 1,
				size: 12
			},
			param: {},
			sort: {}
		} as any;
	}
	if (!condition.paging) {
		condition.paging = {
			index: 1,
			size: 12
		};
	}
	if (!condition.param) {
		condition.param = {} as any;
	}
	if (!condition.sort) {
		condition.sort = {};
	}
	const params = {
		condition,
		modelid,
		refsystemid,
		systemid
	};
	return await service<T>('dataservice.javadsd', params, cache, force_update_cache);
}
